//
//  TabBarViewController.m
//  OrderSys
//
//  Created by JM on 15-9-22.
//  Copyright (c) 2015年 zjlskj. All rights reserved.
//

#import "TabBarViewController.h"
#import "TabBar.h"

@interface TabBarViewController ()<TabBarDelegate>

@end

@implementation TabBarViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    //移除自带的tabBar
   // [self.tabBar removeFromSuperview];
    
    //创建tabBar
    TabBar *tabBar = [[TabBar alloc] init];
    tabBar.delegate = self;
    tabBar.frame = self.tabBar.bounds;
    
    [self.tabBar addSubview:tabBar];
    NSString *imageName = nil;
    NSString *selImageName = nil;
    for (int i = 0; i <self.childViewControllers.count; i++){
        imageName = [NSString stringWithFormat:@"TabBar%dnormal",i];
        selImageName = [NSString stringWithFormat:@"TabBar%dselected",i];
        //添加底部按钮
        [tabBar addTabBarButtonWithName:imageName selName:selImageName];
    }
    
    //获取应用程序中所有的导航条
    UINavigationBar *bar = [UINavigationBar appearance];
    [bar setBarTintColor:[UIColor colorWithRed:20/255.0 green:155/255.0 blue:240/255.0 alpha:1.0]];
    NSDictionary *dict = @{NSForegroundColorAttributeName:[UIColor whiteColor],NSFontAttributeName:[UIFont systemFontOfSize:18 weight:bold]};
    [bar setTitleTextAttributes:dict];
    
}
//代理方法
- (void)tabBar:(TabBar *)tabBar didSelectedIndex:(int)index{
    self.selectedIndex = index;
}

@end
